package define

import (
	"fmt"
	"sync"
	"time"
)

// 用户信息
// {"ret":0,"playerId":3109673861602,"openId":"r","nickName":"","token":"fmYi4pitWvbvLFyDkW-Ih","wsAddress":"wss://proxy-xddq.hdnd01.com/s3109673_ws","createPlayer":false}
type UserInfo struct {
	Ret          int    `json:"ret"`
	PlayerId     int64  `json:"playerId"`
	OpenId       string `json:"openId"`
	NickName     string `json:"nickName"`
	Token        string `json:"token"`
	WsAddress    string `json:"wsAddress"`
	CreatePlayer bool   `json:"createPlayer"`
}

// Logger 日志的相关配置
type Logger struct {
	RollType string
	Dir      string
	File     string
	Count    int32
	Size     int64
	Unit     string
	Level    string
	Compress int64
}

// Db 数据库的连接信息
type Db struct {
	Type     string `json:"type"`
	User     string `json:"user"`
	Pwd      string `json:"pwd"`
	IP       string `json:"ip"`
	Port     string `json:"port"`
	Database string `json:"database"`
	Charset  string `json:"charset"`
}

// Db 数据库的连接信息
type Game struct {
	PlayerId  int64
	Token     string
	LoginTime string
	Phone     string `json:"phone"`
	PassWord  string `json:"passWord"`
	Ptoken    string `json:"pToken"`
	TokenTime string `json:"TokenTime"`
}

// Message 结构体定义
type Message struct {
	SessionID     int
	MessageIDType string
	MessageIDNum  int
	MessageType   int
	PayloadBytes  []byte
	Masking       string
}
type TaskCallbackFunc func(playerId int64, cmd int32, para string) *Message

// Task 定义任务的结构体
type Task struct {
	ID           int32            // 任务ID
	LastRun      time.Time        // 上一次执行时间
	Enabled      bool             // 是否开启执行的标志位
	Function     TaskCallbackFunc // 任务对应的函数
	Interval     time.Duration    // 任务执行的周期，单位为秒
	Desc         string           //任务描述
	Para         string           //函数参数
	StartTime    string           //在哪个时间段开始任务
	EndTime      string           //在哪个时间段结束
	Week         string           //在哪天执行
	MaxRunCount  int              //最多执行次数
	RunCount     int              //当前执行次数
	AntiAttr     int              //指定属性对应的抗性
	EquipmentIdx int              //指定分身执行任务 1 元体 2 阳神 3 阴身
	PriTaskID    int32            //前置任务
	Activity     []int            //当指定活动开启的时候，任意一个
	Mu           sync.Mutex       // 用于保护LastRun字段的互斥锁
}
type EquipmentData struct {
	Data   []byte
	Litter int64
}

// 当前装备信息
type CurrentEquipmentInfo struct {
	Flag        bool              //信息是否有效
	CloneFlag   bool              //是否有仙魔分身
	CloneIdx    int               //分身编号
	CombatValue int64             //妖力
	Attr        [64]int64         //属性
	Equipment   [12]EquipmentInfo //当前装备信息
	Talent      [12]TalentInfo    //当前灵脉信息
}

// 装备信息
type EquipmentInfo struct {
	DealFlag    bool     //是否存在未处理的装备
	Id          string   //装备的ID号
	Level       int64    //装备等级
	Grade       byte     //装备品级
	Part        []byte   //装备部位
	CombatValue int64    //妖力
	Combat      [3]int64 //各分身妖力

	Data2A map[int]EquipmentData
	Data12 map[int]EquipmentData
}

// 当前装备的灵脉信息
type CurrentTalentInfo struct {
	Flag        bool //信息是否有效
	Data        string
	CloneFlag   bool              //是否有仙魔分身
	CloneIdx    int               //分身编号
	CombatValue int64             //妖力
	Attr        [48]int64         //属性
	Equipment   [12]EquipmentInfo //当前装备信息
	Talent      [12]TalentInfo    //当前灵脉信息
}

// 灵脉信息
type TalentInfo struct {
	DealFlag    bool   //是否存在未处理的灵脉
	Level       int64  //灵脉等级
	Grade       byte   //灵脉品级
	Part        []byte //灵脉部位
	Val         int    //灵脉类型
	CombatValue int64  //妖力
	Data2A      map[int]EquipmentData
	Data12      map[int]EquipmentData
}

// 砍树相关信息
type ChopDownTree struct {
	DealChan           chan EquipmentInfo //需要处理装备
	DealTalentChan     chan TalentInfo    //需要处理灵脉
	KanChan            chan int           //需要处理装备
	PeachNum           int32              //桃子数量
	PingNum            int32              //净瓶水数量
	XianNum            int32              //仙玉数量
	StoneNum           int32              //灵石数量
	SpiritualGrassNum  int32              //先天灵草数量
	ChallengeCouponNum int32              //挑战券数量
	XuanHuangGuoNum    int32              //玄黄果数量
	LingQiNum          int32              //灵气数量
	LingZhiNum         int32              //万年灵芝数量
	TianYanLingNum     int32              //天衍令数量
	TengSheNum         int32              //腾蛇信物数量
	WusheShiNum        int32              //五色石数量
	HeroRakingScore    int32              //群英榜积分
	DaoShuNum          int32              //道书数量
	WuDaoStoneNum      int32              //悟道石数量
	Res                int32              //
}

const (
	R_Resource_STR_XianYu       = "100000" //仙玉
	R_Resource_STR_Stone        = "100003" //灵石
	R_Resource_STR_Peech        = "100004" //仙桃
	R_Resource_STR_JingPingShui = "100025" //净瓶水
	R_Resource_STR_LiuLiZhu     = "100029" //琉璃珠
	R_Resource_STR_TianYanLin   = "100044" //天衍令
	R_Resource_STR_KunLunTie    = "100047" //昆仑铁
)

type FortuneType int

const (
	A_Fortune_None       FortuneType = 0
	A_Fortune_Ling_Shou              = 1 //灵兽运势 91-A1 4E
	R_Resource_Jing_Guai             = 2 //精怪运势 A2-B2 4E
	R_Resource_Shen_Tong             = 3 //神通运势 B3-C3 4E
	R_Resource_Nei_Dan               = 4 //内丹运势 C4-D4 4E
	R_Resource_Fa_Bao                = 5 //法宝运势 D5-E5 4E
	A_Fortune_Unkown                 = 6
)

type GameResourceType int

const (
	R_Resource_XianYu       GameResourceType = 0  //仙玉
	R_Resource_Stone                         = 1  //灵石
	R_Resource_Peech                         = 2  //仙桃
	R_Resource_JingPingShui                  = 3  //净瓶水
	R_Resource_LiuLiZhu                      = 4  //琉璃珠
	R_Resource_TianYanLin                    = 5  //天衍令
	R_Resource_KunLunTie                     = 6  //昆仑铁
	R_Resource_Unkown                        = 99 //未知
)

var GameResource = map[GameResourceType][6]string{
	R_Resource_XianYu:       {"仙玉", "2", "4", "8", "15", "30"},
	R_Resource_Stone:        {"灵石", "350", "450", "550", "650", "750"},
	R_Resource_Peech:        {"仙桃", "3", "5", "10", "20", "30"},
	R_Resource_JingPingShui: {"净瓶水", "1", "2", "3", "4", "5"},
	R_Resource_LiuLiZhu:     {"琉璃珠", "1", "2", "3", "4", "5"},
	R_Resource_TianYanLin:   {"天衍令", "1", "2", "5", "10", "15"},
	R_Resource_KunLunTie:    {"昆仑铁", "3", "5", "10", "20", "30"},
	R_Resource_Unkown:       {"未知资源", "1", "2", "3", "4", "5"},
}

// 装备名称
var EquipmentPartName = []string{
	"武器",
	"头部", //1
	"衣服",
	"鞋履",
	"项圈",
	"腰带", //5
	"护腕",
	"宝珠",
	"法器",
	"秘宝",
	"信物", //10
	"傀儡",
}

// 灵脉名称
var TalentPartName = []string{
	"乾",
	"兑",
	"少阴",
	"离",
	"太阴",
	"震",
	"坤",
	"艮",
	"少阳",
	"坎",
	"太阳",
	"巽",
}

// 神兽灵脉
const (
	R_Mythical_Talent_Xuan_Wu   = 50001 //玄武
	R_Mythical_Talent_Bai_Fu    = 50002 //白虎
	R_Mythical_Talent_Teng_She  = 50003 //腾蛇
	R_Mythical_Talent_Gou_Chen  = 50004 //勾陈
	R_Mythical_Talent_Qing_Long = 50005 //青龙
	R_Mythical_Talent_Zhu_Que   = 50006 //朱雀
)

// 神兽灵脉列表
var MythicalTalentList = map[int]string{
	R_Mythical_Talent_Xuan_Wu:   "玄武",
	R_Mythical_Talent_Bai_Fu:    "白虎",
	R_Mythical_Talent_Teng_She:  "腾蛇",
	R_Mythical_Talent_Gou_Chen:  "勾陈",
	R_Mythical_Talent_Qing_Long: "青龙",
	R_Mythical_Talent_Zhu_Que:   "朱雀",
}

// 装备品级
var EquipmentGrade = []string{
	"",
	"凡品", //1
	"下品",
	"中品",
	"上品",
	"极品", //5
	"仙品",
	"完美",
	"先天",
	"至宝",
	"灵宝1星", //10
	"灵宝2星",
	"灵宝3星",
	"灵宝4星",
	"灵宝5星",
	"真宝1星", //15
	"真宝2星",
	"真宝3星",
	"真宝4星",
	"真宝5星",
	"灵器1星", //20
	"灵器2星",
	"灵器3星",
	"灵器4星",
	"灵器5星",
	"神器1星", //25
	"神器2星",
	"神器3星",
	"神器4星",
	"神器5星",
	"仙器1星", //30
	"仙器2星",
	"仙器3星",
	"仙器4星",
	"仙器5星",
	"道器1星", //35
	"道器2星",
	"道器3星",
	"道器4星",
	"道器5星",
	"九天1重", //40
	"九天2重",
	"九天3重",
	"九天4重",
	"九天5重",
	"太乙1重", //45
	"太乙2重",
	"太乙3重",
	"太乙4重",
	"太乙5重",
	"大罗1重", //50
	"大罗2重",
	"大罗3重",
	"大罗4重",
	"大罗5重",
	"造化1重", //55
	"造化2重",
	"造化3重",
	"造化4重",
	"造化5重",
	"混沌至宝", //99
}

// 仙魔分身名称
var CloneName = []string{
	"元体",
	"阳神",
	"阴身",
	"",
}

// 活动信息
const (
	Activity_SUPER_VALUE_GIFT                 = iota //超值礼包
	Activity_Ruins_Battle                            //遗迹争霸
	Activity_Xian_Yuan                               //仙缘
	Activity_Fortune                                 //运势
	Activity_SELF_SELECT_GIFT                        //自选礼包
	Activity_Accumulated_Recharge                    //累计充值
	Activity_Day_Recharge                            //累天充值
	Activity_Reincarnation_Jin_Guai                  //精怪轮回
	Activity_Reincarnation_Shen_Tong                 //神通轮回
	Activity_Reincarnation_Ling_Shou                 //灵兽轮回
	Activity_Reincarnation_Nei_Dan                   //内丹轮回
	Activity_Reincarnation_Xuan_Jue                  //玄诀轮回
	Activity_Reincarnation_Jian_Zhu                  //建筑轮回
	Activity_Reincarnation_Fa_Bao                    //法宝轮回
	Activity_Reincarnation_Fa_Xiang                  //法象轮回
	Activity_FESTIVAL_CELEBRATIONS                   //周年庆
	Activity_WILD_ZONE                               //蛮荒妖域
	Activity_UNION_BATTLE                            //妖盟乱斗
	Activity_Conquer_Eight_Wildernesses              //问鼎八荒
	Activity_UNION_AREA_WAR                          //妖盟攻城战
	Activity_Ask_Grand_Event                         //问道盛会
	Activity_Monster_City_Treasure_Hunt              //妖市寻宝
	Activity_Dragon_Palace_TREASURE                  //龙宫寻宝
	Activity_GOD_ISLAND_GAME_PLANT                   //蓬莱仙岛
	Activity_FAIRY_RABBIT                            //秘境探宝
	Activity_TREASURE_BOWL                           //疯狂聚宝盆
	Activity_GOOD_FORTUNE                            //福泽
	Activity_Dragon_Cave_Secret_Realm                //龙窟秘境
	Activity_Demon_Spirit_Pagoda                     //妖灵宝塔
	Activity_Refining_Conference                     //炼器大会
	Activity_Xiantu_Gathering                        //仙途共聚
	Activity_Journey_Nine_Heavens_Together           //九霄同游
	Activity_Summoning_Dragon                        //召唤神龙
	Activity_Four_Sacred_Treasure_Realms             //四圣宝域
	Activity_Xuanmen_Tribute                         //玄门馈礼
	Activity_Refining_Treasure                       //炼化法宝
	Activity_Reshaping_Dharma_Body                   //重塑法身
	Activity_Sect_Comparison                         //宗门大比
	Activity_Fairyland_Painting                      //画中仙境
	Activity_Immortal_Domain_Business_Journey        //仙域商途
	Activity_Xianyuan_Treasure_Pavilion              //仙缘宝阁
	Activity_Baohuatang                              //宝华堂
	Activity_VALENTINES_DAY                          //鹊桥仙遇
	Activity_Attracting_Wealth_And_Prosperity        //招财金呱
	Activity_Flying_Sword_Treasure                   //飞剑寻宝
	Activity_Reincarnation_Secret_Realm              //轮回秘境
	Activity_Guard_Fairy_Tree                        //守卫仙树
	Activity_Xuanchen_Remembers_Dreams               //玄尘忆梦
	Activity_We_Yound_Scene                          //未央仙境
	Activity_Kun_Lun_War                             //昆仑秘境
	Activity_Road_Defend                             //小妖卫道
	Activity_Pupil                                   //弟子试炼
	Activity_Heaven_Battle                           //大闹天宫
	Activity_XIYOU_PLAYER_BRESS                      //西游伏魔
	Activity_Yu_Kui                                  //御傀争锋
	Activity_                                        //
	Activity_MAX                                     //最大活动索引
)

// 活动列表
var ActivityList = map[int]string{
	Activity_SUPER_VALUE_GIFT:                 "Activity_SUPER_VALUE_GIFT",
	Activity_Ruins_Battle:                     "Activity_Ruins_Battle",
	Activity_Xian_Yuan:                        "Activity_Xian_Yuan",
	Activity_Fortune:                          "Activity_Fortune",
	Activity_SELF_SELECT_GIFT:                 "Activity_SELF_SELECT_GIFT",
	Activity_Accumulated_Recharge:             "Activity_Accumulated_Recharge",
	Activity_Day_Recharge:                     "Activity_Day_Recharge",
	Activity_Reincarnation_Jin_Guai:           "Activity_Reincarnation_Jin_Guai",
	Activity_Reincarnation_Shen_Tong:          "Activity_Reincarnation_Shen_Tong",
	Activity_Reincarnation_Ling_Shou:          "Activity_Reincarnation_Ling_Shou",
	Activity_Reincarnation_Nei_Dan:            "Activity_Reincarnation_Nei_Dan",
	Activity_Reincarnation_Xuan_Jue:           "Activity_Reincarnation_Xuan_Jue",
	Activity_Reincarnation_Jian_Zhu:           "Activity_Reincarnation_Jian_Zhu",
	Activity_Reincarnation_Fa_Bao:             "Activity_Reincarnation_Fa_Bao",
	Activity_Reincarnation_Fa_Xiang:           "Activity_Reincarnation_Fa_Xiang",
	Activity_FESTIVAL_CELEBRATIONS:            "Activity__FESTIVAL_CELEBRATIONS",
	Activity_WILD_ZONE:                        "Activity_WILD_ZONE",
	Activity_UNION_BATTLE:                     "Activity_UNION_BATTLE",
	Activity_Conquer_Eight_Wildernesses:       "Activity_Conquer_Eight_Wildernesses",
	Activity_UNION_AREA_WAR:                   "Activity_UNION_AREA_WAR",
	Activity_Ask_Grand_Event:                  "Activity_Ask_Grand_Event",
	Activity_Monster_City_Treasure_Hunt:       "Activity_Monster_City_Treasure_Hunt",
	Activity_Dragon_Palace_TREASURE:           "Activity_Dragon_Palace_TREASURE",
	Activity_GOD_ISLAND_GAME_PLANT:            "Activity_GOD_ISLAND_GAME_PLANT",
	Activity_FAIRY_RABBIT:                     "Activity_FAIRY_RABBIT",
	Activity_TREASURE_BOWL:                    "Activity_TREASURE_BOWL",
	Activity_GOOD_FORTUNE:                     "Activity_GOOD_FORTUNE",
	Activity_Dragon_Cave_Secret_Realm:         "Activity_Dragon_Cave_Secret_Realm",
	Activity_Demon_Spirit_Pagoda:              "Activity_Demon_Spirit_Pagoda",
	Activity_Refining_Conference:              "Activity_Refining_Conference",
	Activity_Xiantu_Gathering:                 "Activity_Xiantu_Gathering",
	Activity_Journey_Nine_Heavens_Together:    "Activity_Journey_Nine_Heavens_Together",
	Activity_Summoning_Dragon:                 "Activity_Summoning_Dragon",
	Activity_Four_Sacred_Treasure_Realms:      "Activity_Four_Sacred_Treasure_Realms",
	Activity_Xuanmen_Tribute:                  "Activity_Xuanmen_Tribute",
	Activity_Refining_Treasure:                "Activity_Refining_Treasure",
	Activity_Reshaping_Dharma_Body:            "Activity_Reshaping_Dharma_Body",
	Activity_Sect_Comparison:                  "Activity_Sect_Comparison",
	Activity_Fairyland_Painting:               "Activity_Fairyland_Painting",
	Activity_Immortal_Domain_Business_Journey: "Activity_Immortal_Domain_Business_Journey",
	Activity_Xianyuan_Treasure_Pavilion:       "Activity_Xianyuan_Treasure_Pavilion",
	Activity_Baohuatang:                       "Activity_Baohuatang",
	Activity_VALENTINES_DAY:                   "Activity_VALENTINES_DAY",
	Activity_Attracting_Wealth_And_Prosperity: "Activity_Attracting_Wealth_And_Prosperity",
	Activity_Flying_Sword_Treasure:            "Activity_Flying_Sword_Treasure",
	Activity_Reincarnation_Secret_Realm:       "Activity_Reincarnation_Secret_Realm",
	Activity_Xuanchen_Remembers_Dreams:        "Activity_Xuanchen_Remembers_Dreams",
	Activity_Guard_Fairy_Tree:                 "Activity_Guard_Fairy_Tree",
	Activity_We_Yound_Scene:                   "Activity_We_Yound_Scene",
	Activity_Kun_Lun_War:                      "Activity_Kun_Lun_War",
	Activity_Road_Defend:                      "Activity_Road_Defend",
	Activity_Pupil:                            "Activity_Pupil",
	Activity_Heaven_Battle:                    "Activity_Heaven_Battle",
	Activity_XIYOU_PLAYER_BRESS:               "Activity_XIYOU_PLAYER_BRESS",
	Activity_Yu_Kui:                           "Activity_Yu_Kui",
	Activity_:                                 "Activity_",
}

func GetActivityIdxByName(activityName string) int {
	for key, val := range ActivityList {
		if activityName == val {
			return key
		}
	}
	return -1
}

// 装备属性
const (
	Equipment_Data_Attack                            = 1  //攻击
	Equipment_Data_Life                              = 2  //生命
	Equipment_Data_Defense                           = 3  //防御
	Equipment_Data_Agile                             = 4  //敏捷
	Equipment_Attribute_Stun                         = 5  //击晕
	Equipment_Attribute_Critical_Strike              = 6  //暴击
	Equipment_Attribute_Combo_Sttack                 = 7  //连击
	Equipment_Attribute_Dodge                        = 8  //闪避
	Equipment_Attribute_Counter_Attack               = 9  //反击
	Equipment_Attribute_Blood_Suck                   = 10 //吸血
	Equipment_Attribute_Anti_Stun                    = 11 //抗击晕
	Equipment_Attribute_Anti_Critical_Strike         = 12 //抗暴击
	Equipment_Attribute_Anti_Combo_Sttack            = 13 //抗连击
	Equipment_Attribute_Anti_Dodge                   = 14 //抗闪避
	Equipment_Attribute_Anti_Counter_Attack          = 15 //抗反击
	Equipment_Attribute_Anti_Blood_Suck              = 16 //抗吸血
	Special_Attributes_Final_Increase_Damage         = 21 //最终增伤
	Special_Attributes_Final_Reduction_Damage        = 22 //最终减伤
	Special_Attributes_Enhanced_Critical_Damage      = 23 //强化暴伤
	Special_Attributes_Weak_Critical_Damage          = 24 //弱化暴伤
	Special_Attributes_Enhanced_Treatment            = 25 //强化治疗
	Special_Attributes_Weak_Treatment                = 26 //弱化治疗
	Special_Attributes_Enhanced_Spirit_Beast         = 27 //强化灵兽
	Special_Attributes_Weak_Spirit_Beast             = 28 //弱化灵兽
	Special_Attributes_Enhanced_Taoist_Damage        = 31 //强化道法伤害
	Special_Attributes_Ignoring_Combat_Attr          = 32 //无视战斗属性
	Special_Attributes_Ignoring_Combat_Resistance    = 33 //无视战斗抗性
	Special_Attributes_Weak_Taoist_Damage            = 34 //弱化道法伤害
	Special_Attributes_Grid                          = 35 //格挡
	Special_Attributes_Anti_Grid                     = 36 //抗格挡
	Special_Attributes_Armor_Penetration             = 37 //破甲
	Special_Attributes_Anti_Armor_Penetration        = 38 //抗破甲
	Special_Attributes_Shield                        = 39 //护盾
	Special_Attributes_Weak_Shield                   = 40 //弱化护盾
	Special_Attributes_Daofa_Combo                   = 41 //道法连击
	Special_Attributes_Anti_Daofa_Combo              = 42 //抗道法连击
	Special_Attributes_Spirit_Beast_Suppression      = 43 //灵兽压制
	Special_Attributes_Anti_Spirit_Beast_Suppression = 44 //抗灵兽压制
	Special_Attributes_Spirit_Beast_Inspiration      = 45 //灵兽鼓舞
	Special_Attributes_Anti_Spirit_Beast_Inspiration = 46 //抗灵兽鼓舞
	Special_Attributes_Enhanced_Xuanjue              = 47 //强化玄诀
	Special_Attributes_Weak_Xuanjue                  = 48 //弱化玄诀
)

func GetAttrDesc(attr int) string {
	str := ""
	switch attr {
	case Equipment_Attribute_Stun:
		str = "击晕"
		break
	case Equipment_Attribute_Critical_Strike:
		str = "暴击"
		break
	case Equipment_Attribute_Combo_Sttack:
		str = "连击"
		break
	case Equipment_Attribute_Dodge:
		str = "闪避"
		break
	case Equipment_Attribute_Counter_Attack:
		str = "反击"
		break
	case Equipment_Attribute_Blood_Suck:
		str = "吸血"
		break
	case Equipment_Attribute_Anti_Stun:
		str = "抗击晕"
		break
	case Equipment_Attribute_Anti_Critical_Strike:
		str = "抗暴击"
		break
	case Equipment_Attribute_Anti_Combo_Sttack:
		str = "抗连击"
		break
	case Equipment_Attribute_Anti_Dodge:
		str = "抗闪避"
		break
	case Equipment_Attribute_Anti_Counter_Attack:
		str = "抗反击"
		break
	case Equipment_Attribute_Anti_Blood_Suck:
		str = "抗吸血"
		break
	case Special_Attributes_Final_Increase_Damage:
		str = "最终增伤"
		break
	case Special_Attributes_Final_Reduction_Damage:
		str = "最终减伤"
		break
	case Special_Attributes_Enhanced_Critical_Damage:
		str = "强化暴伤"
		break
	case Special_Attributes_Weak_Critical_Damage:
		str = "弱化暴伤"
		break
	case Special_Attributes_Enhanced_Treatment:
		str = "强化治疗"
		break
	case Special_Attributes_Weak_Treatment:
		str = "弱化治疗"
		break
	case Special_Attributes_Enhanced_Spirit_Beast:
		str = "强化灵兽"
		break
	case Special_Attributes_Weak_Spirit_Beast:
		str = "弱化灵兽"
		break
	case Special_Attributes_Enhanced_Taoist_Damage:
		str = "强化道法伤害"
		break
	case Special_Attributes_Ignoring_Combat_Attr:
		str = "无视战斗属性"
		break
	case Special_Attributes_Ignoring_Combat_Resistance:
		str = "无视战斗抗性"
		break
	case Special_Attributes_Weak_Taoist_Damage:
		str = "弱化道法伤害"
		break
	case Special_Attributes_Grid:
		str = "格挡"
		break
	case Special_Attributes_Anti_Grid:
		str = "抗格挡"
		break
	case Special_Attributes_Armor_Penetration:
		str = "破甲"
		break
	case Special_Attributes_Anti_Armor_Penetration:
		str = "抗破甲"
		break
	case Special_Attributes_Shield:
		str = "护盾"
		break
	case Special_Attributes_Weak_Shield:
		str = "弱化护盾"
		break
	case Special_Attributes_Daofa_Combo:
		str = "道法连击"
		break
	case Special_Attributes_Anti_Daofa_Combo:
		str = "抗道法连击"
		break
	case Special_Attributes_Spirit_Beast_Suppression:
		str = "灵兽压制"
		break
	case Special_Attributes_Anti_Spirit_Beast_Suppression:
		str = "抗灵兽压制"
		break
	case Special_Attributes_Spirit_Beast_Inspiration:
		str = "灵兽鼓舞"
		break
	case Special_Attributes_Anti_Spirit_Beast_Inspiration:
		str = "抗灵兽鼓舞"
		break
	default:
		str = "未知"
		break
	}
	return str
}

// 资源信息
type ResourceInfo struct {
	Type     GameResourceType
	Level    int
	Location int
	IsTake   bool
}

type AttrData struct {
	Data   []byte
	Litter int64
}

type PersonInfo struct {
	ID          string //ID
	UserID      string //用户ID
	Name        string //用户名字
	CombatValue int64  //妖力
}

type SkyWarPersonInfo struct {
	ID          string //ID
	UserID      string //用户ID
	Name        string //用户名字
	CombatValue int64  //妖力
}

type SkyWarPersonInfoArray []SkyWarPersonInfo

func (a SkyWarPersonInfoArray) Len() int           { return len(a) }
func (a SkyWarPersonInfoArray) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a SkyWarPersonInfoArray) Less(i, j int) bool { return a[i].CombatValue > a[j].CombatValue }

// 征战诸天信息
type SkyWarInfo struct {
	Flag         bool //成功返回
	RefreshCount int  //剩余刷新次数
	FightCount   int  //剩余挑战次数
	People       [3]SkyWarPersonInfo
}

// 问道盛会信息
type AskWayInfo struct {
	Flag         bool //成功返回
	RefreshCount int  //剩余刷新次数
	FightCount   int  //剩余挑战次数
	Group        int  //组别
	People       []SkyWarPersonInfo
}

// 九幽争霸-灵气信息
type HolyLandSpiInfo struct {
	Spi         int64     //当前灵气
	SpiLimit    int64     //灵气上线
	Save        int64     //当前存储灵气
	SaveLimit   int64     //存储灵气上线
	CombatValue int64     //妖力
	EndTime     time.Time //活动时间
	Defeated    int64     //被击败
	EndATime    time.Time //结束时间
}

// 九幽争霸-地点信息
type HolyLandAddInfo struct {
	PlaceId  int    //地址ID
	Place    string //地址ID
	YmID     string //妖盟ID
	Res3     int    //3
	Res4     int    //4
	YMName   string //5 妖盟名称
	Res6     int    //6
	Res7     int    //7
	Res8     int    //8
	Res9     int    //9
	Res10    int    //10
	Res11    int    //11
	Res12    int    //12
	Res13    int    //13
	IsYM     bool   //是否是妖盟
	IsOccupy bool   //是否被己方占领
}

// 九幽争霸-地图信息
type HolyLandMapInfo struct {
	Add []HolyLandAddInfo
}

// 九幽争霸-地图信息
type HolyLandAddMapInfo struct {
	Name    string //地点名称
	Level   int    //地点级别 1-妖盟 2-1级灵脉 3-2级灵脉 4-3级灵脉 5-4级灵脉 6-怪兽
	Link    []int  //相邻地点ID
	IsStart bool   //起始地方
	IsOE    bool   //是否被敌方占领
	IsOS    bool   //是否被己方占领
}

// 九幽争霸-信息
type HolyLandInfo struct {
	Spi         HolyLandSpiInfo            //灵气信息
	Map         HolyLandMapInfo            //地图信息
	SelfPlaceID int                        //大本营的ID
	MapD        map[int]HolyLandAddMapInfo //
}

// 蓬莱仙岛-灵气信息
type GodIslandSpiInfo struct {
	Spi         int64     //当前灵气
	SpiLimit    int64     //灵气上线
	Save        int64     //当前存储灵气
	SaveLimit   int64     //存储灵气上线
	CombatValue int64     //妖力
	EndTime     time.Time //活动时间
	Defeated    int64     //被击败
	EndATime    time.Time //结束时间
}

// 蓬莱仙岛-地点信息
type GodIslandAddInfo struct {
	PlaceId  int    //地址ID
	Place    string //地址ID
	YmID     string //妖盟ID
	Res3     int    //3
	Res4     int    //4
	YMName   string //5 妖盟名称
	Res6     int    //6
	Res7     int    //7
	Res8     int    //8
	Res9     int    //9
	Res10    int    //10
	Res11    int    //11
	Res12    int    //12
	Res13    int    //13
	IsYM     bool   //是否是妖盟
	IsOccupy bool   //是否被己方占领
}

// 蓬莱仙岛-地图信息
type GodIslandMapInfo struct {
	Add []GodIslandAddInfo
}

// 蓬莱仙岛-地图信息
type GodIslandAddMapInfo struct {
	Name    string //地点名称
	Level   int    //地点级别 1-妖盟 2-1级灵脉 3-2级灵脉 4-3级灵脉 5-4级灵脉 6-怪兽
	Link    []int  //相邻地点ID
	IsStart bool   //起始地方
	IsOE    bool   //是否被敌方占领
	IsOS    bool   //是否被己方占领
}

// 蓬莱仙岛-信息
type GodIslandInfo struct {
	Spi         GodIslandSpiInfo            //灵气信息
	Map         GodIslandMapInfo            //地图信息
	SelfPlaceID int                         //大本营的ID
	MapD        map[int]GodIslandAddMapInfo //
}

// 星宿试炼怪物信息
type StartTrialInfo struct {
	ID          string //成功返回
	FightCount  int    //剩余挑战次数
	Res0        int64  //
	Res1        int64  //
	CombatValue int64  //妖力
	Res2        int64  //
	Res3        int64  //
	Res4        int64  //
	Res5        int    //
}

type UnionAreaWarSceneInfo struct {
	ID    string //妖盟ID
	UseID string //妖盟当前用户ID
}

// 妖盟对决
type UnionDuiJueAllInfo struct {
	ID         string //妖盟ID
	UName      string //妖盟名称
	FightCount int    //剩余对决次数
}

// 妖盟对决
type UnionDuiJueInfo struct {
	ID          string //玩家ID
	Name        string //名字
	CombatValue int64  //妖力
	Data        string //未知数据
	FightCount  int    //剩余攻击次数
}
type UnionDuiJueInfoArray []UnionDuiJueInfo

func (a UnionDuiJueInfoArray) Len() int           { return len(a) }
func (a UnionDuiJueInfoArray) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a UnionDuiJueInfoArray) Less(i, j int) bool { return a[i].CombatValue > a[j].CombatValue }

// 妖盟攻城战
type UnionAreaWarInfo struct {
	ID              string //妖盟ID
	Name            string //妖盟名字
	Defeated        bool   //是否被击败
	AllCombatValue  int64  //总妖力
	LeftCombatValue int64  //剩余妖力
	Ranking         int    //妖盟排名
	CityLevel       byte   //城池等级
}
type UnionAreaWarInfoArray []UnionAreaWarInfo

func (a UnionAreaWarInfoArray) Len() int           { return len(a) }
func (a UnionAreaWarInfoArray) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a UnionAreaWarInfoArray) Less(i, j int) bool { return a[i].Ranking > a[j].Ranking }

type UnionHonorHallInfo struct {
	ID string //妖盟ID
}

// 冒险怪物信息
type MonsterInfo struct {
	Data map[int]AttrData
}

// 蛮荒妖域信息
type ActivityWildInfo struct {
	ID       string //ID
	NeedStop bool   //无体力需要停止任务
	Layer    int    //当前探险层数
}

type WildZoneInfo struct {
	ID          string               //ID
	Name        string               //用户名字
	CombatValue int64                //妖力
	TeamName    string               //队伍名称
	Person      []WildZonePersonInfo //组队信息
	Invite      []WildZonePersonInfo //已申请人员信息
}

type WildZonePersonInfo struct {
	UserID      string //用户ID
	Name        string //用户名字
	CombatValue int64  //妖力
}

type WildZonePersonInfoSort []WildZonePersonInfo

func (a WildZonePersonInfoSort) Len() int           { return len(a) }
func (a WildZonePersonInfoSort) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a WildZonePersonInfoSort) Less(i, j int) bool { return a[i].CombatValue > a[j].CombatValue }

// 蛮荒妖域互助信息
type ActivityWildHelpInfo struct {
	FindUserID   string    //发现者ID
	FindUserName string    //发现者名字
	ID           string    //ID
	CombatValue  int64     //妖力
	HelpCount    int       //协助次数
	IsMonster    bool      //是否是怪物
	Time         time.Time //允许攻击的时间
}

// 仙官送福礼物信息
type SendGiftInfo struct {
	ID       string //玩家ID
	Name     string //名字
	GiftID   string //礼物ID
	GiftType string //礼物类型
}

// 用户背包数据
type UserBagInfo struct {
	Str    string //数据
	ID     string //物品ID
	Num    int32  //物品数量
	NumStr string //物品数量16进制字符串
}

// 仙桃乐宴信息
type PeachBanquetInfo struct {
	ID     string //玩家ID
	Name   string //名字
	GiftID string //礼物ID
}

// 仙桃乐宴加入信息
type PeachBanquetJoinInfo struct {
	GiftID string //宴会ID
	ID     string //道友ID
	Name   string //道友名字
	Flag   bool
	A      byte
	B      byte
}

// 仙桃乐宴加列表信息
type PeachBanquetListInfo struct {
	Join PeachBanquetJoinInfo
}
type JuLingZhenLingQiInfo struct {
	ID string //灵气ID
}

// 聚灵阵信息
type JuLingZhenInfo struct {
	ID      string    //用户ID
	LzID    string    //灵阵ID
	YmID    string    //妖盟ID
	Name    string    //灵阵名字
	Num     byte      //已入阵人数
	Title   byte      //是否有称号 F9 F7
	IsSelf  bool      //是否是自己的灵阵
	Time    time.Time //到期时间
	LinQ    int       //灵气速度
	AllLinQ int64     //灵气值
}

type JuLingZhenInfoSortByGrade []JuLingZhenInfo

func (a JuLingZhenInfoSortByGrade) Len() int      { return len(a) }
func (a JuLingZhenInfoSortByGrade) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a JuLingZhenInfoSortByGrade) Less(i, j int) bool {
	if a[i].IsSelf && !a[j].IsSelf {
		return true
	}
	if !a[i].IsSelf && a[j].IsSelf {
		return false
	}
	return a[i].AllLinQ > a[j].AllLinQ
}

// 邮件信息
type EmailInfo struct {
	MsgID   string   //邮件ID
	Title   string   //邮件标题
	Content string   //邮件内容
	Gift    []string //存在的礼包
}

// 宗门弟子信息
type ZoneMenInfo struct {
	PID      string //所属道友ID
	PName    string //所属道友名字
	Name     string //弟子姓名
	Index    int    //弟子序号
	Num      string //弟子编号
	Level    byte   //弟子等级
	Aptitude []byte //弟子特质 1 平平无奇 2 灵心慧性 3 天纵之姿 4 神骨天生 5 造化圣体 6 成帝之姿
	Schedule int    //培养进度
	Res8     string //
	Gender   byte   //性别类型
	IsBoy    bool   //是男孩
	Res10    byte   //
	Attr     int    //属性
	AttrVal  int64  //属性值
	Limit    byte   //限制结伴弟子等级
	Pairing  bool   //是否在结伴中
	IsDamage bool   //是否是增减伤属性
}

type ZoneMenInfoSort []ZoneMenInfo

func (a ZoneMenInfoSort) Len() int           { return len(a) }
func (a ZoneMenInfoSort) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ZoneMenInfoSort) Less(i, j int) bool { return a[i].AttrVal > a[j].AttrVal }

type ZoneMenInfoOtherSort []ZoneMenInfo

func (a ZoneMenInfoOtherSort) Len() int           { return len(a) }
func (a ZoneMenInfoOtherSort) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ZoneMenInfoOtherSort) Less(i, j int) bool { return a[i].Level > a[j].Level }

// 砍价人员信息
type BargainingPeopleInfo struct {
	ID    string //ID
	Name  string //名字
	Price int32  //砍价额度
}

// 妖盟砍价信息
type BargainingProgressInfo struct {
	ID         string                 //砍价的ID
	Time       time.Time              //砍价结束时间
	MinPrice   int32                  //最低砍价额度
	CutPrice   int32                  //已砍价
	Negotiated []BargainingPeopleInfo //已砍价人员
	UnPriced   []BargainingPeopleInfo //未砍价人员
}

// 妖力值显示
func GetCombatValueDesc(val int64) string {
	if val < 0 {
		return "-" + GetCombatValueDesc(-val)
	} else if val == 0 {
		return "0"
	} else if val >= 100000000 { // 如果大于等于1亿
		return fmt.Sprintf("%.2f亿", float32(val/1000000)/100)
	} else if val >= 10000 { // 如果大于等于1万
		return fmt.Sprintf("%.2f万", float32(val/100)/100)
	}
	return fmt.Sprintf("%d", val)
}

// 妖盟悬赏品级
var DemonLeagueOfferGrade = map[byte]string{
	0xE9: "[黄-灵草]",
	0xEA: "[黄-玄铁]",
	0xEB: "[黄-仙木]",
	0xEC: "[玄-玄水]",
	0xED: "[玄-仙人参]",
	0xEE: "[玄-水灵兽]",
	0xEF: "[地-仙卷图]",
	0xF0: "[地-沧海灵珠]",
	0xF1: "[地-邪修]",
	0xF2: "[天-仙品丹药]",
	0xF3: "[天-无名神剑]",
	0xF4: "[天-太上仙鼎]",
	0xF5: "[神-造化三生莲]",
	0xF6: "[神-太古镇魔匣]",
	0xF7: "[神-紫霄宫神女]",
}

func GetDemonLeagueOfferGradeDesc(idx byte) string {
	if _, ok := DemonLeagueOfferGrade[idx]; ok {
		return DemonLeagueOfferGrade[idx]
	}
	return ""
}

// 仙友列表
var DestinySelfList = map[string]string{
	"914E": "珞樱",
	"924E": "小紫",
	"934E": "花想容",
	"944E": "沐瑶",
	"954E": "阎嫣",
	"964E": "云霓",
	"974E": "",
	"984E": "",
	"994E": "",
	"9A4E": "",
	"9B4E": "扶摇",
	"9C4E": "蝶裳",
	"9D4E": "凤求凰",
	"9E4E": "燕归来",
	"9F4E": "",
	"A04E": "",
	"A14E": "",
	"A24E": "",
	"A34E": "",
	"A44E": "",
	"A54E": "王贵人",
	"A64E": "",
	"A74E": "",
	"A84E": "",
	"A94E": "玄莺",
	"AA4E": "",
	"AB4E": "",
	"AC4E": "白骨夫人",
	"AD4E": "",
	"AE4E": "",
	"AF4E": "",
	"B04E": "",
	"B14E": "",
	"B24E": "",
	"B34E": "",
	"B44E": "彩鳞",
	"B54E": "",
	"B64E": "",
	"B74E": "楚钰",
	"B84E": "",
	"B94E": "",
	"BA4E": "",
	"BB4E": "",
	"BC4E": "",
	"BD4E": "",
	"BE4E": "",
	"BF4E": "",
}

func GetDestinyName(id string) string {
	if _, ok := DestinySelfList[id]; ok {
		return DestinySelfList[id]
	}
	return ""
}

// 查看所有道友悬赏情况结果
type DemonLeagueAllPersonInfo struct {
	Name        string //用户名字
	LeagueName  string //所在妖盟名字
	Grade       byte   //护送的品级
	ID          string //ID
	UserID      string //用户ID
	CombatValue int64  //妖力
}

// 查看所有道友悬赏怪物情况结果
type DemonLeagueAllMonsterInfo struct {
	ID     string //ID
	UserID string //用户ID
	Name   string //用户名字
	Grade  byte   //护送的品级
}

// 查看所有道友悬赏怪物情况结果
type DemonLeagueAllInfo struct {
	PersonInfo  []DemonLeagueAllPersonInfo
	MonsterInfo []DemonLeagueAllMonsterInfo
}

// 查看指定道友信息
type DemonLeaguePersonInfo struct {
	Name       string //用户名字
	LeagueName string //所在妖盟名字
	Grade      byte   //护送的品级
	ID         string //ID
	UserID     string //用户ID
}
type DemonLeagueAllPersonInfoSortByGrade []DemonLeagueAllPersonInfo

func (a DemonLeagueAllPersonInfoSortByGrade) Len() int           { return len(a) }
func (a DemonLeagueAllPersonInfoSortByGrade) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a DemonLeagueAllPersonInfoSortByGrade) Less(i, j int) bool { return a[i].Grade > a[j].Grade }

// 妖盟-查看仙居信息结果
type XianjuItemInfo struct {
	ID     string    //ID
	Type   string    //类型
	Y      byte      //纵坐标
	X      byte      //横坐标
	Status byte      //状态
	Level  int       //等级
	Time   time.Time //时间
	Num    string    //数量
}

// 仙居物品
type XianjuGoodsInfo struct {
	ID     string //物品ID
	IDi    int    //物品ID int类型
	Name   string //物品名称
	Level  int    //物品等级
	Num    int64  //物品数量
	Price  int    //物品价格
	APrice int    //物品活动价格
}

// 妖盟-查看仙居信息结果
type XianjuInfo struct {
	Level      int                     //等级
	Prosperity int64                   //繁荣度
	PeachCoin  int32                   //桃妖币
	LingCao    int64                   //灵草数量
	MapD       map[int]XianjuGoodsInfo //物品数据
	Items      []XianjuItemInfo        //物品
}

// 查看仙居协助的结果
type XianjuAssistanceInfo struct {
	Name string //用户名字
	ID   string //ID
	Res1 string //
	Res2 string //
}

// 查看仙居协助的结果
type XianjuLevelInfo struct {
	Level      int   //等级
	Prosperity int64 //繁荣度
}

// 查看仙居协助的结果
type XianjuPriceInfo struct {
	IDi    int //物品ID int类型
	APrice int //物品活动价格
}

type XianYuOfferingSacrificesInfo struct {
	NeedOffer bool      //是否需要开始供奉
	Time      time.Time //完成供奉的时间
}

type UnionBattlePeopleInfo struct {
	ID          string //ID
	Name        string //用户名字
	CombatValue int64  //妖力
}

type FortuneTaskMap struct {
	ID    string //任务ID
	Name  string //任务名称
	Count int64  //任务完成需要执行次数
	Num   int64  //任务当前执行次数
	Done  bool   //是否已完成
	Take  bool   //是否已领取
}
type FortuneTask struct {
	IDi   int    //任务ID
	ID    string //任务ID
	Name  string //任务名称
	Count int64  //任务完成次数
	Done  bool   //是否已完成
	Take  bool   //是否已领取
}
type ActivityDataInfo struct {
	FortuneType FortuneType   //运势类型
	FortuneTask []FortuneTask //运势任务
	Count       int           //总抽奖次数
}

type ActivityInfo struct {
	ID         string    //活动ID
	Name       string    //活动名称
	MainIndex  []byte    //主索引 //可能为2个字节
	SubIndex   byte      //副索引
	StartATime time.Time //活动开始时间
	EndATime   time.Time //活动结束时间
	StartTime  time.Time //活动任务开始时间
	EndTime    time.Time //活动任务结束时间
}
type ActivityInfoSort []ActivityInfo

func (a ActivityInfoSort) Len() int      { return len(a) }
func (a ActivityInfoSort) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ActivityInfoSort) Less(i, j int) bool {
	iLen := int(a[i].MainIndex[0])
	if len(a[i].MainIndex) > 1 {
		iLen += (int(a[i].MainIndex[1]) - 1) * 128
	}
	jLen := int(a[j].MainIndex[0])
	if len(a[j].MainIndex) > 1 {
		jLen += (int(a[j].MainIndex[1]) - 1) * 128
	}
	if iLen == jLen {
		return a[i].SubIndex < a[j].SubIndex
	}
	return iLen < jLen
}

// 妖盟乱斗匹配结果
type UnionBattleMatchInfo struct {
	ID              string //妖盟ID
	Name            string //妖盟名字
	AlreadyMatch    bool   //已经匹配
	SelfCombatValue int64  //妖力
	NotBuy          bool   //未购买增幅
	PeopleInfo      []UnionBattlePeopleInfo
}
type UnionBattlePeopleInfoByCombatValue []UnionBattlePeopleInfo

func (a UnionBattlePeopleInfoByCombatValue) Len() int      { return len(a) }
func (a UnionBattlePeopleInfoByCombatValue) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a UnionBattlePeopleInfoByCombatValue) Less(i, j int) bool {
	return a[i].CombatValue > a[j].CombatValue
}

type PetInfo struct {
	ID     [3]byte //灵兽ID
	Name   string  //灵兽名称
	HasBuy bool    //是否已购买
}

// 背包中的灵兽信息
type PackPetInfo struct {
	Idx   string  //灵兽ID
	ID    [3]byte //灵兽类型ID
	Name  string  //灵兽名称
	Level int     //等级
	Grade int     //星级
}

// 灵兽信息
type AllPetInfo struct {
	IsByLogin bool          //是否是登录收到的信息
	PackPet   []PackPetInfo //所有灵兽信息
	PetInfo   [3]PetInfo    //召唤灵兽信息
}

// 查看妖盟悬赏
type DemonLeagueInfo struct {
	ID        string //任务ID
	Grade     byte   //护送的品级
	NeedTake  bool   //需要护送
	Taking    bool   //护送中
	NeedClaim bool   //护送完成
	Done      bool   //全部护送完成
	Time0     time.Time
	Time1     time.Time
	Person    []DemonLeaguePersonInfo //组队信息
}

type HeroInfo struct {
	NotHuman    bool   //人机
	Ranking     int    //排名
	RankStr     string //排名字符串
	ID          string //ID
	Name        string //名字
	CombatValue int64  //妖力
	R18         string
	R20         string
	R28         string
	R30         string
}

// 群英榜信息
type AllHeroInfo struct {
	FightCount int //剩余挑战次数
	Hero       []HeroInfo
}

// 用户资源信息
type UserResourceInfo struct {
	UserId       string          //用户ID
	Name         string          //用户姓名
	AllLevel     [2]byte         //资源等级预览
	ResourceInfo [6]ResourceInfo //资源信息
	IsTake       bool            //是否有人在采摘
	TakeIdx      int             //可以采摘的编号
	Time         time.Time       //下一次采集的时间
}

// 仙域商图地点信息
type SkyTradeAddInfo struct {
	ID        string //地点ID
	IDi       int    //地点ID整形
	Name      string //地点名
	Specialty int    //特产
	Lack      int    //紧缺
	Goods     [15]SkyTradeGoodsInfo
}

// 仙域商图货物信息
type SkyTradeGoodsInfo struct {
	ID     string //商品ID
	IDi    int    //商品ID整形
	Name   string //商品名称
	Count  int    //剩余数量
	Price  int    //初始价格
	CPrice int    //当前价格
}

// 仙域商图信息
type SkyTradeInfo struct {
	FightCount int //总灵玉
	Add        []SkyTradeAddInfo
}

// 用户资源信息
type FudiHomeManageInfo struct {
	UserId       string       //用户ID
	ResourceInfo ResourceInfo //资源信息
}

type FuDiData struct {
	LeftMouseNum int                   //剩余空闲老鼠数量
	MouseTotal   int                   //老鼠总数量
	TakeFuDiChan chan UserResourceInfo //需要采摘
	MsgChan      chan Message          //需要发送的消息
	Config       [7]int
	UserIdMap    map[string]UserResourceInfo
	UserInfo     UserResourceInfo
}

type FightInfo struct {
	MaoXianAttr       chan int        //冒险
	ZhenYaoTaAttr     chan int        //镇妖塔
	ZhenHuoMiJingAttr chan int        //真火秘境
	ChallengeCoupon   chan int        //斗法挑战
	SkyWar            chan SkyWarInfo //查看征战诸天
	AskWay            chan AskWayInfo //查看问道盛会
	CombatValue       int64           //当前分身妖力
	OfferCount        int             //悬赏挑战次数
}

// 轮回秘境信息
type LunHuiMiJingInfo struct {
	YmID    string //妖盟ID
	Name    string //妖盟名字
	Ranking int    //排名
}
type LunHuiMiJingInfoByRanking []LunHuiMiJingInfo

func (a LunHuiMiJingInfoByRanking) Len() int      { return len(a) }
func (a LunHuiMiJingInfoByRanking) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a LunHuiMiJingInfoByRanking) Less(i, j int) bool {
	return a[i].Ranking < a[j].Ranking
}

// 妖盟寻宝-画卷信息
type UnionTreasureHuntInfo struct {
	Addr   string //地点ID
	Status int    //是否已解锁地点 0 未解锁 1 已解锁 2 需要挖宝 3 挖宝完成
	Num    int    //画卷数量
}

// 妖盟寻宝-查看解锁情况
type AllUnionTreasureHuntInfo struct {
	Info []UnionTreasureHuntInfo //画卷信息
	Time time.Time               //活动截止时间
}

// 神兽灵脉
const (
	Msg_Type_text      = iota //文本消息
	Msg_Type_YM_Master        //妖盟悬赏消息
	Msg_Type_YMDB             //妖盟夺宝索要消息
	Msg_Type_Xian_Ju          //仙居邀请消息
)

// 妖盟消息
type MsgYaoMen struct {
	ID   string    //发送人ID
	Name string    //发送人名字
	Time time.Time //发送时间
	Type int       //消息类型
	Msg  string    //消息内容
}

// 妖盟寻宝-画卷领取
type TreasureHuntDrawInfo struct {
	NID  string //赠送人ID
	Name string //赠送人名字
	Addr string //画卷ID
	GID  string //画卷礼物ID
}

// 龙窟秘境人员信息
type LongKuPersonInfo struct {
	ID          string    //人员ID
	X           int       //当前位置X坐标
	Y           int       //当前位置Y坐标
	Name        string    //名字
	Strength    int       //剩余体力
	CombatValue int64     //妖力
	Time        time.Time //下一次体力刷新时间
	Level       int       //当前层数
}

// 龙窟秘境地图信息
type LongKuMapInfo struct {
	Person  []LongKuPersonInfo
	YinYu   bool     //是否已拿到阴玉
	YangYu  bool     //是否已拿到阳玉
	MapData [][]byte //地图数据
	Gift    []byte   //未领取的礼物ID
}

// 龙窟秘境体力信息
type LongKuStrengthInfo struct {
	Strength int       //剩余体力
	Time     time.Time //下一次体力刷新时间
	Ranking  int       //当前排名
}

// 道途试练信息
type DaoTuInfo struct {
	R1           byte
	R2           int
	R3           byte
	R4           byte
	Layer        int
	ChallengeNum byte
	R7           byte
	Time         time.Time //
}

// 上古战场礼物信息
type WarSeasonGiftInfo struct {
	Name string //送礼人名
	ID   string //礼物ID
}

// 山海万象组队信息
type MountainSeaTeamInfo struct {
	Team   []PersonInfo
	Person []PersonInfo
}

// 解析守卫仙树
type GuardFairyTreeInfo struct {
	Level    string //关卡
	Now      byte   //关卡
	NowLevel string //现在的关卡
}

// 小妖卫道
type RoadDefendInfo struct {
	Level    byte //关卡
	Now      byte //关卡
	Strength byte //体力
	ID       []string
	NowLevel byte //现在的关卡
}

type DestinyTaskInfo struct {
	ID   string    //任务ID
	Idx  byte      //任务序号
	Done bool      //是否已完成
	Time time.Time //任务完成时间
}

// 瑶池仙踪信息
type DestinyFightInfo struct {
	Task       []DestinyTaskInfo //任务
	TaskCount  [4]byte           //任务次数
	FightCount byte              //已挑战次数
}

// 瑶池仙踪仙友信息
type DestinySelfInfo struct {
	ID         string //ID
	Name       string //名字
	Charm      int64  //魅力值
	Delegation byte   //委派次数
	Fight      byte   //挑战次数
}

type DestinySelfInfoSort []DestinySelfInfo

func (a DestinySelfInfoSort) Len() int           { return len(a) }
func (a DestinySelfInfoSort) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a DestinySelfInfoSort) Less(i, j int) bool { return a[i].Charm > a[j].Charm }

// 瑶池仙踪挑战道友信息
type DestinyPersonInfo struct {
	TaskID      string  //ID
	UserID      string  //用户ID
	Name        string  //用户名字
	CombatValue int64   //妖力
	CharmList   []int64 //魅力值
	Charm       int64   //总魅力值
}

// 瑶池仙踪挑战信息
type DestinyFightListInfo struct {
	Person []DestinyPersonInfo //
}

type DestinyPersonInfoSort []DestinyPersonInfo

func (a DestinyPersonInfoSort) Len() int           { return len(a) }
func (a DestinyPersonInfoSort) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a DestinyPersonInfoSort) Less(i, j int) bool { return a[i].Charm < a[j].Charm }

// 仙宫信息
type XianGongInfo struct {
	NeedAppreciate bool     //需要赞赏
	Id             []string //未领取仙宫ID
}
type Point struct {
	X, Y byte
}

type PointSort []Point

func (p PointSort) Len() int      { return len(p) }
func (p PointSort) Swap(i, j int) { p[i], p[j] = p[j], p[i] }
func (p PointSort) Less(i, j int) bool {
	if p[i].X != p[j].X {
		return p[i].X < p[j].X
	}
	return p[i].Y < p[j].Y
}

// 未央仙境信息
type WeYoundInfo struct {
	Level     byte      //关卡
	Spirit    int64     //灵力
	Points    int64     //积分
	Strength  byte      //体力
	X         byte      //当前位置X坐标
	Y         byte      //当前位置Y坐标
	NextFloor bool      //下一层是否开启
	EndTime   time.Time //活动结束时间
	Point     []Point   //已探索位置
}

// 斗法信息
type DouFaInfo struct {
	Idx         byte   //序号
	UserID      string //用户ID
	Name        string //用户名字
	CombatValue int64  //妖力
	Points      int64  //积分
}

type DouFaInfoSort []DouFaInfo

func (a DouFaInfoSort) Len() int           { return len(a) }
func (a DouFaInfoSort) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a DouFaInfoSort) Less(i, j int) bool { return a[i].Points > a[j].Points }

// 炼器大会信息
type CastSwordInfo struct {
	Board       [][]int //棋盘数据
	CombatValue int64   //当前积分
	Points      int64   //历史积分
	Strength    int     //剩余体力
}

// 弟子试炼神游信息
type PupilTravelInfo struct {
	Level     byte   //关卡
	Day       byte   //天数
	EventType byte   //事件类型
	EventId   string //事件ID
	EventDesc string //事件描述
}

// 弟子试炼冒险信息
type PupilExploreInfo struct {
	Day         byte     //天数
	EventType   byte     //事件类型
	EventId     string   //事件ID
	EventDesc   string   //事件描述
	SkillListId []string //待选技能
}

// 弟子试炼冒险弟子信息
type PupilRandomInfo struct {
	Count byte //剩余刷新次数
	Info  []PupilInfo
}

// 弟子试炼冒险弟子信息
type PupilInfo struct {
	ID      string //ID
	Life    int64  //生命
	Attack  int64  //攻击
	Defence int64  //防御
	SkillId string //技能ID
	Flag    byte   //
}
type ShenQuDetailInfo struct {
	ID      string    //ID
	Count   byte      //次数
	EndTime time.Time //活动结束时间
}

// 神躯信息
type ShenQuInfo struct {
	A []ShenQuDetailInfo
	B []ShenQuDetailInfo
}

type UserGameData struct {
	UserID                string                     //玩家ID E2 83 86 B8 C0 5A
	YaoMengID             string                     //妖盟ID
	WarSeasonID           string                     //幽冥战场ID
	UserInfo              UserInfo                   //用户信息
	ChopDownTree          ChopDownTree               //砍树
	FightInfo             FightInfo                  //挑战相关
	Xianju                XianjuInfo                 //仙居信息
	PetCall               int64                      //灵兽召唤次数
	PackPet               []PackPetInfo              //背包所有灵兽信息
	Activity              [Activity_MAX]ActivityInfo //活动信息
	CurrentAttr           int                        //当前装备属性
	HasBuyZhenBao         bool                       //是否已购买珍宝阁
	ConfigAttr            [6]byte                    //属性
	ConfigAntiAttr        [6]byte                    //抗性
	ConfigTalentAttr      [6]int                     //灵脉
	EquipmentCloneFlag    bool                       //是否存在仙魔分身
	EquipmentInfoFlag     [3]bool                    //是否已获取到对于分身的信息
	CurrentEquipmentIdx   int                        //当前装备 0  1  2
	CurrentEquipmentInfo  [3]CurrentEquipmentInfo    //装备信息
	Task                  []Task
	TaskResetFlag         bool
	FuDiData              FuDiData             //福地参数
	ZoneMenLastInfo       []ZoneMenInfo        //上一个宗门弟子信息
	ZoneMenInfo           []ZoneMenInfo        //宗门未结伴信息
	HolyLandInfo          HolyLandInfo         //九幽争霸
	GodIslandInfo         GodIslandInfo        //蓬莱仙岛
	WildOil               int32                //蛮荒妖域剩余香油
	LongKuStrength        int                  //龙窟秘境剩余体力
	LongKuGrass           int32                //龙窟秘境剩余龙须草
	CondensingFragrance   int32                //未央仙境归元凝神香数量
	PeachBanquetJoin      PeachBanquetJoinInfo //仙桃乐宴加入信息
	UnionDuiJueFightCount int                  //妖盟对决攻击次数
	DestinySelfInfo       []DestinySelfInfo    //瑶池仙踪仙友信息
	DestinyFightCount     byte                 //瑶池仙踪已挑战次数
	CastSwordLiquid       int32                //炼器大会甘露仙液
	XIYOUCombatValue      int64                //西游伏魔妖力
	XIYOUGinsengFruit     int32                //西游伏魔人参果
	XIYOULevel            byte                 //道运等级
	Passes                int64                //通过的关卡
	XIYOUDealChan         chan EquipmentInfo   //西游伏魔需要处理装备
	XIYOUKanChan          chan int             //西游伏魔开始砍树
}

type ConditionTaskInfo struct {
	TaskID     string    //任务ID
	Progress   int64     //当前进度
	FinishFlag bool      //是否已完成
	GetFlag    bool      //是否已领取
	FinishTime time.Time //完成时间
}
type ConditionListInfo struct {
	ActivityID string              //活动ID
	Task       []ConditionTaskInfo //任务信息
}

type XIYOUPlayerInfo struct {
	CombatValue int64     //妖力
	Passes      int64     //通过关卡数量
	PassesStr   string    //通过关卡数量
	Level       byte      //道运等级
	Updating    bool      //是否在更新等级
	UpdateTime  time.Time //完成时间
}
type XIYOUSecretInfo struct {
	Level byte //幻境等级
	ID    []string
}

// 游戏用户数据
var UserGameDataMap = make(map[int64]*UserGameData)

func (ri UserResourceInfo) ToString() string {
	str := "" //ri.UserId
	for _, rData := range ri.ResourceInfo {
		if rData.IsTake {
			str += fmt.Sprintf(" %5s 【%d】 ", GameResource[rData.Type][0], rData.Level)
		} else {
			str += fmt.Sprintf(" %5s %d ", GameResource[rData.Type][0], rData.Level)
		}
	}
	return str
}
